home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / errcheck.arc / errorchk.st
Text File  |  1989-03-23  |  4KB  |  147 lines

  1.     Having had a small problem recently with this program that is in
  2. Comp.sources.atari.st (address error on exit of other - GEM - program)
  3. I have added a fix. The reason seems to be that when some GEM programs
  4. terminate they are using the GEM-exit vector, and the exit routine
  5. still relies on A4 having a valid contents (I'm not sure). After I
  6. modified the code to save A4 on the stack the problem disappeared.
  7.  
  8.     Here is the relevant part of the code (comments omitted), with 2
  9. instructions added:
  10.  
  11.  
  12. DTOPWAIT
  13.       MOVE.L   $602C,A0
  14.       MOVEQ.L  #0,D1
  15.       BRA.S    DTOPAREND
  16. DTOPARNT
  17.       ADDQ.L   #1,D1
  18.       MOVE.L   36(A0),A0
  19. DTOPAREND
  20.       TST.L    (A0)
  21.       BNE.S    DTOPARNT
  22.       CMP.B    #3,D1
  23.       BNE.S    DTWEND
  24.       MOVE.L   A4,-(SP)            *  Added this instruction to save A4 ....
  25.       LEA      WAITMSG(PC),A4
  26.       BRA.S    DTOPW3
  27. DTOPW2
  28.       EXT.W    D0
  29.       MOVE.W   D0,-(SP)
  30.       MOVE.W   #2,-(SP)
  31.       MOVE.W   #3,-(SP)
  32.       TRAP     #BIOS
  33.       ADDQ.L   #6,SP
  34. DTOPW3
  35.       MOVE.B   (A4)+,D0
  36.       BNE.S    DTOPW2
  37.       MOVE.W   #2,-(SP)
  38.       MOVE.W   #2,-(SP)
  39.       TRAP     #BIOS
  40.       ADDQ.L   #4,SP
  41.       MOVE.L   (SP)+,A4            *  .... and this one to restore A4
  42. DTWEND
  43.       MOVE.L   OLDVEC(PC),-(SP)
  44.       RTS
  45.  
  46.  
  47.       Leo.                         * Not an instruction, more a periferal 8-)
  48.  
  49.  
  50. Here is another small memory-resident program to be placed in the AUTO folder.
  51.     Did you also had times you wanted to see a program's final (error?) message
  52. when it flashed over your screen and the desktop was painted all over it.
  53.     This little program checks whenever a program exits if the caller was the
  54. desktop (it does this by following the links in the basepages); if so, a 
  55. message is printed and you can press a key to continue.
  56.     The program sets the GEM program exit vector that is at address 0x408; this
  57. vector usually points to a RTS statement (i.e. does nothing). After a keypress
  58. a jump is made to the old vector (in case it WAS used).
  59.     This program also prevents the need of coding similar messages into every 
  60. program that can be called from the desktop.
  61.     It was assembled using the assembler and linker that come with the GST-C
  62. compiler, resulting in a program length of 240 bytes. 
  63.  
  64.     My name and address:
  65.  
  66.    L.J.M. de Wit
  67.    Nachtegaallaan 7
  68.    5731XP Mierlo
  69.    Holland.
  70.  
  71. ---------------  H E R E   I T   A L L   S T A R T S  -------------------------
  72.  
  73.  
  74.       MODULE  DTOPWAIT
  75.       SECTION S.CCODE
  76.  
  77. GEMDOS    EQU 1
  78. BIOS      EQU 13
  79. PTERMRES  EQU $31
  80. SETEXC    EQU 5
  81. ESC       EQU $1B
  82.  
  83. DTWINIT
  84.       MOVE.L   #-1,-(SP)
  85.       MOVE.W   #$102,-(SP)
  86.       MOVE.W   #SETEXC,-(SP)
  87.       TRAP     #BIOS             * Save old GEM exit vector
  88.       ADDQ.L   #8,SP
  89.       LEA.L    OLDVEC(PC),A0
  90.       MOVE.L   D0,(A0)
  91.       PEA      DTOPWAIT
  92.       MOVE.W   #$102,-(SP)
  93.       MOVE.W   #SETEXC,-(SP)
  94.       TRAP     #BIOS             * Set new GEM exit vector
  95.       ADDQ.L   #8,SP
  96.       MOVE.L   4(SP),A0
  97.       MOVE.L   #$100,D0          * Base page
  98.       ADD.L    12(A0),D0         * + text length
  99.       ADD.L    20(A0),D0         * + data length
  100.       ADD.L    28(A0),D0         * + bss length
  101.       CLR.W    -(SP)             * Return value: 0 for success
  102.       MOVE.L   D0,-(SP)          * # bytes to keep
  103.       MOVE.W   #PTERMRES,-(SP)   * Keep process
  104.       TRAP     #GEMDOS           * Stops here...
  105.  
  106. DTOPWAIT
  107.       MOVE.L   $602C,A0
  108.       MOVEQ.L  #0,D1
  109.       BRA.S    DTOPAREND
  110. DTOPARNT
  111.       ADDQ.L   #1,D1
  112.       MOVE.L   36(A0),A0
  113. DTOPAREND
  114.       TST.L    (A0)
  115.       BNE.S    DTOPARNT
  116.       CMP.B    #3,D1
  117.       BNE.S    DTWEND
  118.       LEA      WAITMSG(PC),A4
  119.       BRA.S    DTOPW3
  120. DTOPW2
  121.       EXT.W    D0
  122.       MOVE.W   D0,-(SP)
  123.       MOVE.W   #2,-(SP)
  124.       MOVE.W   #3,-(SP)
  125.       TRAP     #BIOS
  126.       ADDQ.L   #6,SP
  127. DTOPW3
  128.       MOVE.B   (A4)+,D0
  129.       BNE.S    DTOPW2
  130.       MOVE.W   #2,-(SP)
  131.       MOVE.W   #2,-(SP)
  132.       TRAP     #BIOS
  133.       ADDQ.L   #4,SP
  134. DTWEND
  135.       MOVE.L   OLDVEC(PC),-(SP)
  136.       RTS
  137.  
  138.       SECTION  S.DATA
  139.  
  140. OLDVEC   DC.L  0
  141. WAITMSG  DC.B  13,10,ESC,'K',ESC,'p',9,9
  142.          DC.B  'Program finished; hit a key to return to desktop',ESC,'q',0
  143.  
  144.       END
  145.  
  146.  
  147.